package zip;

import Util.CreateFileUtil;
import org.openjdk.jmh.annotations.Benchmark;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * JDK CutTest test
 */
public class CutTest extends TestParent {
    protected byte[] compressFile = CreateFileUtil.getBytesByFile("./demo.json");
    @Benchmark
    public String UnFormatJsonPattern() {
        String dest = "";
        if (jsonStr != null) {
            Pattern p = Pattern.compile("\\s*|\t|\r|\n");
            Matcher m = p.matcher(new String(compressFile));
            dest = m.replaceAll("");
        }
        return dest;

    }
    @Benchmark
    public String UnFormatJsonReplaceAll() {
        String dest = new String(compressFile);
        dest = dest.replaceAll(" ","");
        dest = dest.replaceAll("\n","");
        return dest;
    }
}
